<?php

        // update language can
    switch ($change_old)
        {
            case 'Deutsch':$sql6= "update settings set can='Deutsch', cande='Deutsch', canen='German', canes='Alemán', canru='Немецкий' where customerid = ". $customerid;break;
            case 'Englisch':$sql6= "update settings set can='Englisch', cande='Englisch', canen='English', canes='Inglés', canru='Английский' where customerid = ". $customerid;break;
            case 'Spanisch':$sql6= "update settings set can='Spanisch', cande='Spanisch', canen='Spanish', canes='Español', canru='Испанский' where customerid = ". $customerid;break;
            case 'Russisch':$sql6= "update settings set can='Russisch', cande='Russisch', canen='Russian', canes='Ruso', canru='Русский' where customerid = ". $customerid;
        }
    $db_sel6 = mysql_query_secure( $sql6 );

    // check, if oldlanguage = newlanguage
	$sql8 = " select cande,learnde from settings ";
    $sql8 .= " where customerid = ". $customerid;
    $db_sel8 = mysql_query_secure( $sql8 );
    while ($row = mysql_fetch_array( $db_sel8, MYSQL_ASSOC))
	{
	// update internal variables
	$learn_lang = $row['learnde'];
	$can_lang = $row['cande'];
	
    if ( $row['learnde'] == $change_old )
    {
        // update language can
	    $sql9 = " update settings set ";
        $sql9 .= " learn = '-', learnde = '-', learnen = '-', learnes = '-', learnru = '-', langpair = '' ";
        $sql9 .= " where customerid = ". $customerid;
        $db_sel9 = mysql_query_secure( $sql9 );
    }
    elseif ( $row['learnde'] == '' or $row['learnde'] == '-' ) {}
    else
    {
        //check langpair
  	    $sql13 = " select langpairid from langpairs_german ";
        $sql13 .= " where learn = '". $row['learnde'] . "' and ";
        $sql13 .= " can = '". $row['cande'] . "'";
        $db_sel13 = mysql_query_secure( $sql13 );
        while ($row = mysql_fetch_array( $db_sel13, MYSQL_ASSOC))
		{
            $langpair = $row['langpairid'];
        }

        if ( $langpair <> '' )
		{
            // update langpair
	        $sql11 = " update settings set ";
            $sql11 .= " langpair = '". $langpair . "' ";
            $sql11 .= " where customerid = ". $customerid;
            $db_sel11 = mysql_query_secure( $sql11 );

        }

    }
}
?>

